<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Bit stuffing</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Bit_stuffing"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Bit_stuffing rootpage-Bit_stuffing skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Bit stuffing</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p class="mw-empty-elt">
</p>
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */
.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style>
<p>In <a href="Data_transmission" class="mw-redirect" title="Data transmission">data transmission</a> and <a href="Telecommunications" title="Telecommunications">telecommunications</a>, <b>bit stuffing</b> (also known—uncommonly—as <b>positive justification</b>) is the insertion of non-information <a href="Binary_digit" class="mw-redirect" title="Binary digit">bits</a> into <a href="Data" title="Data">data</a>. Stuffed bits should not be confused with <a href="Overhead_bit" title="Overhead bit">overhead bits</a>.
</p><p>Bit stuffing is used for various purposes, such as for bringing <a href="Bit_stream" class="mw-redirect" title="Bit stream">bit streams</a> that do not necessarily have the same or rationally related <a href="Bit_rate" title="Bit rate">bit rates</a> up to a common rate, or to fill <a href="Buffer_(telecommunication)" class="mw-redirect" title="Buffer (telecommunication)">buffers</a> or <a href="Data_frame" class="mw-redirect" title="Data frame">frames</a>. The location of the stuffing bits is communicated to the receiving end of the <a href="Data_link" title="Data link">data link</a>, where these extra bits are removed to return the bit streams to their original bit rates or form. Bit stuffing may be used to synchronize several channels before <a href="Multiplexing" title="Multiplexing">multiplexing</a> or to rate-match two single channels to each other.
</p><p>Another use of bit stuffing is for <a href="Run_length_limited" class="mw-redirect" title="Run length limited">run length limited</a> coding: to limit the number of consecutive bits of the same value in the data to be transmitted. A bit of the opposite value is inserted after the maximum allowed number of consecutive bits. Since this is a general rule the receiver doesn't need extra information about the location of the stuffing bits in order to do the de-stuffing. This is done to create additional signal transitions to ensure reliable reception or to escape special reserved code words such as frame <a href="Sync_sequence" class="mw-redirect" title="Sync sequence">sync sequences</a> when the data happens to contain them.
</p>
<p>Bit stuffing does not ensure that the payload is intact (<i>i.e.</i> not corrupted by transmission errors); it is merely a way of attempting to ensure that the transmission starts and ends at the correct places. <a href="Error_detection_and_correction" title="Error detection and correction">Error detection and correction</a> techniques are used to check the frame for corruption after its delivery and, if necessary, the frame will be re-sent.
</p>
<div class="mw-heading mw-heading2"><h2 id="Zero-bit_insertion">Zero-bit insertion</h2></div>
<p>The <a href="NRZI" class="mw-redirect" title="NRZI">NRZI</a> coding scheme transmits a 0 bit as a signal transition, and a 1 bit as no change. In this case, bit stuffing is most easily described as the insertion of a 0 bit after a long run of 1 bits.
</p><p>It was popularized by IBM's <a href="Synchronous_Data_Link_Control" title="Synchronous Data Link Control">SDLC</a> (later renamed <a href="HDLC" class="mw-redirect" title="HDLC">HDLC</a>), and is also used in Low- and full-speed <a href="USB" title="USB">USB</a>.
</p><p>After a long sequence of 1 bits there would be no transitions in the transmitted data, and it would be possible for the transmitter and receiver clocks to lose synchronisation. By inserting a 0 after five (SDLC) or six (USB) consecutive 1 bits the transmitter guarantees a maximum of six (SDLC) or seven (USB) bit times between transitions. The receiver can synchronise its clock against the transitions to ensure proper data recovery.
</p><p>In SDLC the transmitted bit sequence "01111110" containing six adjacent 1 bits is the <a href="High-Level_Data_Link_Control#Synchronous_framing" title="High-Level Data Link Control">Flag byte</a>. Bit stuffing ensures that this pattern can never occur in normal data, so it can be used as a marker for the beginning and end of the frame without any possibility of being confused with normal data.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p><p>The main disadvantage of bit-stuffing is that the <a href="Code_rate" title="Code rate">code rate</a> is unpredictable; it depends on the data being transmitted.
</p><p><i>Source: from <a href="Federal_Standard_1037C" title="Federal Standard 1037C">Federal Standard 1037C</a> in support of <a href="MIL-STD-188" title="MIL-STD-188">MIL-STD-188</a></i>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Consistent_Overhead_Byte_Stuffing" title="Consistent Overhead Byte Stuffing">Consistent Overhead Byte Stuffing</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Kevin R. Fall and W. Richard Stevens, <i>TCP/IP Illustrated Volume 1: The Protocols</i>, Second Edition, Addison-Wesley, 2012, Kindle Edition loc 3505</span>
</li>
</ol></div></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-04-18" href="https://en.wikipedia.org/wiki/?title=Bit_stuffing&oldid=1286187581">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>